package com.weixing.mall.provider.model.excel;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.weixing.mall.base.constant.DatePattern;
import com.weixing.mall.base.constant.GlobalConstant;
import com.weixing.mall.provider.api.model.enums.OrderTypeEnum;
import com.weixing.mall.provider.model.enums.OrderIsPrintEnum;
import com.weixing.mall.provider.model.enums.OrderStateEnum;
import com.weixing.mall.provider.model.enums.SealMatchRuleEnum;
import lombok.Data;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;

/**
 * @Author 0202
 * @Date 2020-8-20 16:23:02
 * @Version 1.0
 */
@Data
@ContentRowHeight(100)
public class OrderListPCED {
    @ExcelProperty("序号")
    private Long xh;
    @ExcelProperty("图片")
    @ExcelIgnore
    private String goodsImg;
    @ExcelProperty("图片")
    private URL img;
    @ExcelProperty("订单编号")
    private String orderSn;
    @ExcelProperty("分类名称")
    private String catName;
    @ExcelProperty("系列名称")
    private String sysName;
    @ExcelProperty("活动名称")
    private String actName;
    @ExcelProperty("订单状态")
    @ExcelIgnore
    private OrderStateEnum orderStatus;
    @ExcelProperty("订单状态")
    private String orderStatusStr;
    @ExcelProperty("订单类型")
    @ExcelIgnore
    private OrderTypeEnum orderType;
    @ExcelProperty("订单类型")
    private String orderTypeStr;
    @ExcelProperty("货号")
    private String goodsSn;
    @ExcelProperty("商品名称")
    private String goodsName;
    @ExcelProperty("款号")
    private String styleNo;
    @ExcelProperty("颜色")
    private String color;
    @ExcelProperty("尺码")
    private String size;
    @ExcelProperty("颜色/尺码")
    @ExcelIgnore
    private String productSkuDesp;
    @ExcelProperty("下单人")
    private String buyer;
    @ExcelProperty("收货人")
    private String contactUser;
    @ExcelProperty("收货人手机号")
    private String contactPhone;
    @ExcelProperty("身高")
    private Double height;
    @ExcelProperty("体重")
    private Double weight;
    @ExcelProperty("地址")
    private String addrDetail;
    @ExcelProperty("客服备注")
    private String kefuRemark;
    @ExcelProperty("快递方式")
    private String expressName;
    @ExcelProperty("快递单号")
    private String expressSn;
    @ExcelProperty("支付流水号")
    private String outTradeNo;
    @ExcelProperty("所属客服")
    private String customer;
    @ExcelProperty("审核时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date auditTime;
    @ExcelProperty("所属仓库")
    private String depotName;

    @ExcelProperty("仓库编码")
    private String depotSn;

    @ExcelProperty("客户备注")
    private String remark;

    @ExcelProperty("所属代理商")
    private String agentName;
    @ExcelProperty("所属发货员")
    private String shipper;
    @ExcelProperty("是否换货")
    @ExcelIgnore
    private Integer afterSaleTag;
    @ExcelProperty("是否换货")
    private String afterSaleTagStr;
    @ExcelProperty("下单时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date createdTime;
    @ExcelProperty("匹配")
    @ExcelIgnore
    private SealMatchRuleEnum mateRule;
    @ExcelProperty("匹配")
    private String mateRuleStr;
    @ExcelProperty("是否推送商品码")
    @ExcelIgnore
    private OrderIsPrintEnum isGoodsSnPrint;
    @ExcelProperty("是否推送商品码")
    private String pushCodeStr;
    @ExcelProperty("订单价格")
    private Double orderPrice;
    @ExcelProperty("操作时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date operationTime;











    public void setGoodsImg(String goodsImg){
        this.goodsImg = goodsImg;
        try {
            if (StrUtil.isNotEmpty(goodsImg)){
                this.img=new URL(GlobalConstant.IMG_PATH_URL +goodsImg+GlobalConstant.IMG_PATH_URL_SUFFIX);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }

    public void setOrderStatus(OrderStateEnum orderStatus){
        this.orderStatus = orderStatus;
        if(orderStatus != null){
            this.orderStatusStr = orderStatus.getDesp();
        }
    }

    public void setOrderType(OrderTypeEnum orderType){
        this.orderType = orderType;
        if(orderType != null){
            this.orderTypeStr = orderType.getDesp();
        }
    }

    public void setIsGoodsSnPrint(OrderIsPrintEnum isGoodsSnPrint){
        this.isGoodsSnPrint = isGoodsSnPrint;
        if(isGoodsSnPrint != null){
            this.pushCodeStr = isGoodsSnPrint.getDesp();
        }
    }

    public void setMateRule(SealMatchRuleEnum mateRule){
        this.mateRule = mateRule;
        if(mateRule != null){
            this.mateRuleStr = mateRule.getDesp();
        }
    }

    public void setAfterSaleTag(Integer afterSaleTag){
        this.afterSaleTag = afterSaleTag;
        if (afterSaleTag != null && afterSaleTag == 1 ) {
            this.afterSaleTagStr = "是";
        }else{
            this.afterSaleTagStr = "否";
        }
    }
}
